{% extends "base.html" %}
{% load i18n %}
{% block content %}
    <h2>{% trans "Reservas" %}</h2>
    <div>
        {% trans "Total" %}: {{ hits }} {% trans "reservas" %}{% if is_paginated %}, {% trans "mostrando de a" %} {{ results_per_page }}{% endif %}.
    </div>
    {% for reserva in object_list %}
        <p class="reserva">
            <div>
                {% trans "Socio" %}: {{ reserva.socio }}
            </div>
            <div>
                {% trans "Dia" %}: {{ reserva.dia }} {% trans "de" %} {{ reserva.mes }}
            </div>
            <div>
                {% trans "Hora" %}: {{ reserva.hora }}:00 {% trans "horas" %}
            </div>
            <div>
                {% trans "Cancha" %}: {{ reserva.cancha }}
            </div>
            <div>
                {% trans "Junto a" %}: {{ reserva.invitado }}
            </div>
            <form method="post" action="/administrador/reserva/sancionar/" style="float: left; clear: none; padding-right: 100px;">
                <input type="hidden" name="reserva" id="reserva" value="{{ reserva.id }}" />
                <input type="hidden" name="usuario" id="usuario" value="{{ reserva.socio.id }}" />
                <input type="hidden" name="next" id="next" value="/administrador/reservas/?page={{ page }}" />
                <input type="hidden" name="confirmada" id="confirmada" />
                <button name="sancionar" id="sancionar" value="sancionar" type="submit"><img src="/media/images/sancion.png" alt="" /> {% trans "Sancionar" %}!</button>
            </form>
            {% if reserva.cancelada %}
                <div class="cancelada">
                    {% trans "Cancelada por" %} {{ reserva.cancelada_por }} {% trans "el" %} {{ reserva.cancelada_el }}
                </div>
            {% else %}
                {% if reserva.cancelable_por_admin %}
                <form method="post" action="/cancelar/reserva/" onSubmit="if(confirm('{% trans "Confirme que realmente desea cancelar la reserva." %}')){document.getElementById('confirmada').value='true'; return true;}else{return false;}">
                    <input type="hidden" name="reserva" id="reserva" value="{{ reserva.id }}" />
                    <input type="hidden" name="next" id="next" value="/administrador/reservas/?page={{ page }}" />
                    <input type="hidden" name="confirmada" id="confirmada" />
                    <button name="cancelar" id="cancelar" value="cancelar" type="submit"><img src="/media/images/cancel.gif" alt="" /> {% trans "Cancelar" %}!</button>
                </form>
                {% else %}
                    <div class="pendiente">
                        Reserva no cancelada. No Cancelable.
                    </div>
                {% endif %}
            {% endif %}
        </p>
    {% endfor %}
    {% if is_paginated %}
        <p class="paginado">
            {% if has_previous %}
                <a href="?page=1">{% trans "Primera" %}</a>
                <a href="?page={{ previous }}">{% trans "Anterior" %}</a>
            {% endif %}
                {% trans "Página" %} {{ page }} {% trans "de" %} {{ pages }}
            {% if has_next %}
                <a href="?page={{ next }}">{% trans "Siguiente" %}</a>
                <a href="?page=last">{% trans "Última" %}</a>
            {% endif %}
        </p>
    {% endif %}
{% endblock %}
